<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2021/3/30
  Time: 17:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 后台大布局 - Layui</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">

    <jsp:include page="../common/header.jsp"></jsp:include>

    <jsp:include page="../common/menu.jsp"></jsp:include>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend>默认表格</legend>
            </fieldset>

            <fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;">
                <div>
                    <button id="insertDept" type="button" class="layui-btn layui-btn-normal">添加部门</button>
                </div>
            </fieldset>
            <div class="layui-form">
                <table class="layui-table">
                    <colgroup>
                        <col width="150">
                        <col width="150">
                        <col width="200">
                        <col>
                    </colgroup>
                    <thead>

                    <tr>
                        <th>
                            <input type="checkbox" name="like1[read]" lay-skin="primary" title="阅读">
                        </th>
                        <th>id</th>
                        <th>部门名称</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach items="${list}" var="dept"  >
                        <tr>
                            <td>

                            </td>
                            <td>${dept.id}</td>
                            <td>${dept.deptName}</td>
                            <td>
                                <a href="${pageContext.request.contextPath}/dept/updateUI?id=${dept.id}" class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                                <a onclick="delDept('${dept.id}')" href="javascript:;">删除</a>
                            </td>
                        </tr>
                    </c:forEach>

                    </tbody>
                </table>
            </div>

        </div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © layui.com - 底部固定区域
    </div>
</div>
<script src="${pageContext.request.contextPath}/layui/layui.js"></script>
<script>
    //JavaScript代码区域
    layui.use(['jquery','layer'], function(){
        var $ = layui.$;
        var layer = layui.layer;
        // 获取id
        $("#insertDept").click(function (){
            location.href = "${pageContext.request.contextPath}/dept/insertUI";
        })

    });

    function delDept(id){
        layer.confirm('确认删除么？', {icon: 3, title:'提示'}, function(index){

            //调用删除
            location.href = "${pageContext.request.contextPath}/dept/del?id="+id;
            layer.close(index);
        });
    }
</script>
</body>
</html>
